<%@page import="com.mysql.cj.xdevapi.JsonArray"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.sql.Array"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@ page import="java.io.IOException" %>
<%@page
import="java.io.PrintWriter"
import ="java.net.URLEncoder"
import=" java.sql.Connection"
import ="java.sql.DriverManager"
import ="java.sql.PreparedStatement"
import ="java.sql.ResultSet"
import ="javax.servlet.ServletException"
import=" javax.servlet.annotation.WebServlet"
import ="javax.servlet.http.HttpServlet"
import ="javax.servlet.http.HttpServletRequest"
import=" javax.servlet.http.HttpServletResponse"
import=" javax.swing.JOptionPane" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>查看厂库物资</title>
</head>
<%try {request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/yj?autoReconnect=true&serverTimezone=GMT","root","root");
String q=new String();
String q2=new String();
String q3=new String();
String q4=new String();
String q5=new String();
PreparedStatement j=con.prepareStatement("select * from goods where ckid=?");
j.setString(1, request.getParameter("id"));
ResultSet res=j.executeQuery();
if(!res.next()){
	PreparedStatement k=con.prepareStatement("insert into goods(ckid,name1,count1,name2,count2,name3,count3,name4,count4,name5,count5)value(?,?,?,?,?,?,?,?,?,?,?)");
	k.setString(1, request.getParameter("id"));
	k.setString(2, "帐篷");
	k.setString(3, "0");
	k.setString(4, "食品");
	k.setString(5, "0");
	k.setString(6, "医疗物资");
	k.setString(7, "0");
	k.setString(8, "水");
	k.setString(9, "0");
	k.setString(10, "器械");
	k.setString(11, "0");
	k.executeUpdate();
	k.close();
}
else{
	
	 q=res.getString("count1");
	 q2=res.getString("count2");
	 q3=res.getString("count3");
	 q4=res.getString("count4");
	 q5=res.getString("count5");
	
}
j.close();
con.close();

		request.setAttribute("q",q);
		request.setAttribute("q2", q2);
		request.setAttribute("q3", q3);
		request.setAttribute("q4", q4);
		request.setAttribute("q5", q5);

}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} %>
<body>
<table>
<tr><td>帐篷</td><td><%=request.getAttribute("q") %></td><tr>
<tr><td>食品</td><td><%=request.getAttribute("q2") %></td><tr>
<tr><td>医疗物资</td><td><%=request.getAttribute("q3") %></td><tr>
<tr><td>水</td><td><%=request.getAttribute("q4") %></td><tr>
<tr><td>器械</td><td><%=request.getAttribute("q5") %></td><tr>
</table>

<a href="addgoods.jsp?id=<%=request.getParameter("id") %>">添加物资</a>
</body>
</html>